<template>
	<view class="">
		<view class="inp_warp">
			<view class="inp_title key">名称<span>*</span></view>
			<view class="form_right" >
				<input type="text" class="rightinput" :class="name ? 'valueActive' : '' " v-model="name" placeholder="请输入名称" placeholder-style="font-size:30rpx;color: #999;" >
			</view>
		</view>
		<view class="inp_warp">
			<view class="inp_title key">联系电话<span>*</span></view>
			<view class="form_right" >
				<input type="text" class="rightinput" :class="phone ? 'valueActive' : '' " v-model="phone" placeholder="请输入联系电话" placeholder-style="font-size:30rpx;color: #999;" >
			</view>
		</view>
		<view class="inp_warp">
			<view class="inp_title key">联系人</view>
			<view class="form_right" >
				<input type="text" class="rightinput" :class="username ? 'valueActive' : '' " v-model="username" placeholder="请输入联系人" placeholder-style="font-size:30rpx;color: #999;" >
			</view>
		</view>
		<view class="fllow_area">
			<view class="area_head">地址</view>
			<textarea v-model="address" :class="address ? 'valueActive' : '' "  placeholder="请输入地址" placeholder-class="ri_label" />
		</view>
		<view class="inp_warp">
			<view class="inp_title key">权重</view>
			<view class="form_right" >
				<input type="number" class="rightinput" :class="sort ? 'valueActive' : '' " v-model="sort" placeholder="权重" placeholder-style="font-size:30rpx;color: #999;" >
			</view>
		</view>
		<view class="button" @click="$noMultipleClicks(sureSave)">
			保存
		</view>
		<view class="botsec"></view>
	</view>
</template>

<script>
	import { netSupplierEdit, netSupplierDetail } from '@/api/api.js'
	
	export default{
		data() {
			return{
				noClick:true,    //防止  重复点击
				name:'',
				username:'',
				phone:'',
				address:'',
				sort:'',
				id:''
			}
		},
		onLoad(options) {
			this.id = options.id
			this.getDetail()
		},
		methods:{
			getDetail() {
				netSupplierDetail({id:this.id}).then(res=>{
					res = res.data
					this.name = res.name
					this.username = res.username
					this.phone = res.phone
					this.address = res.address
					this.sort = res.sort
				})
			},
			sureSave() {
				if(!this.name){
					uni.showToast({
						title:'请填写名称',
						icon:'none'
					})
					return
				}
				if(!this.phone){
					uni.showToast({
						title:'请填写联系电话',
						icon:'none'
					})
					return
				}
				let params = {
					name:this.name,
					username:this.username,
					phone:this.phone,
					address:this.address,
					sort:this.sort,
					id:this.id
				}
				netSupplierEdit(params).then(res=>{
					uni.showToast({
						title:res.msg,
						icon:'none'
					})
					setTimeout(()=>{
						uni.navigateBack({
							delta:1
						})
					},2000)
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.valueActive{
		color:#333;
	}
	.inp_warp {
		padding:30rpx;
		background: #fff;
		display: flex;
		justify-content: space-between;
		align-items: center;
		border-bottom: 1rpx solid #EDEDED;
		.inp_title {
			font-size: 26rpx;
		}
	
		.form_right {
			display: flex;
			justify-content: flex-end;
			align-items: center;
			color: #999;
			min-width:450rpx;
			text-align: right;
			image {
				width: 40rpx;
				height: 40rpx;
				margin: 28rpx 5rpx 0 0;
			}
			.rightinput{
				width:100%;
				text-align: right;
			}
			.radiowarp{
				display: flex;
				justify-content: flex-end;
				align-items: center;
				radio{
					transform: scale(0.7);
				}
			}
		}
	}
	.fllow_area {
		background-color: #fff;
		margin-bottom: 30rpx;
		padding-bottom: 30rpx;
		color: #999;
		.area_head {
			height: 100rpx;
			line-height: 100rpx;
			font-size: 32rpx;
			padding: 0 30rpx;
			text {
				color: #f00;
			}
		}
		textarea {
			width: 80%;
			height: 300rpx;
			padding: 30rpx;
			background: #f8f8f8;
			margin: 0 auto;
		}
	}
</style>